<template>
  <van-nav-bar title="我的" fixed placeholder />

  <div class="app">
    <van-image round width="10rem" height="10rem" :src="userObj.avatar" />
    <div>账号名：{{ userObj.username }}</div>
    <div>昵称{{ userObj.nickname }}</div>

    <van-button type="danger" block @click="exitFn()">退出</van-button>
    <van-button type="danger" block @click="$router.push('/userInfoEdit')">编辑用户头像</van-button>
  </div>
</template>
<script>
import { getUserInfoAPI } from "@/api/user";
import { removeToken } from "@/utils/token";

export default {
  data() {
    return {
      userObj: {},
    };
  },
  methods: {
    exitFn() {
      removeToken();
      this.$router.push("/");
    },
  },
  mounted() {},
  activated() {
    getUserInfoAPI().then((r) => {
      console.log(r.data);
      this.userObj = r.data.data[0];
    });
  },
};
</script>
<style lang="css" scoped>
.app {
  padding: 10px;
  display: flex;
  flex-direction: column;
  /* justify-content: center;
   */
  align-items: center;
}
</style>
